# spectral.R
# produces model runs with different numbers of topics, to guide selection process numerically
# for article "Citizens' preferences for tackling climate change. Quantitative and qualitative analyses of their freely formulated solutions"
# Endre Tvinnereim, May 2017

require(stm)

cd("o:/2.221-climdo/data")

load("prepared_corpus.RData")

str(out)

K <- c(3:20)

kresult <- searchK(out$documents, out$vocab, K,
                   # prevalence =~ age + education + gender + political_interest,
                   data=meta)

save(kresult, file="kresult.Rdata")

plot(kresult)

plot(kresult$results$K, kresult$results$exclus)

plot(kresult$results$K, kresult$results$semcoh)

plot(kresult$results$exclus, kresult$results$semcoh, pch=".")

text(kresult$results$exclus, kresult$results$semcoh, as.character(kresult$results$K))


